package com.igame.mapper;

import com.igame.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Insert("insert into oreder(id, user_id, goods_id, state, crate_time, complete_time) values (#{id},#{userId},#{goodsId},#{state},#{createTime},#{completeTime})")
    int insert(Order order);

    @Select("select * from oreder where user_id=#{userId} and goods_id=#{goodsId}")
    Order OrderExist(Integer userId,Integer goodsId);

    @Update("update oreder set state=#{state}  where user_id=#{userId} and goods_id=#{goodsId}")
    int updateState(Order order);

    @Select("select goods_id from oreder where user_id =#{userId} and state = #{state}")
    List<Integer> selectByState(Integer userId,Integer state);
}
